package com.huaxinkaiye.activity;

import com.huaxinkaiye.R;
import com.huaxinkaiye.adapter.ShenPiAdapter;
import com.huaxinkaiye.widget.SimpleFooter;
import com.huaxinkaiye.widget.SimpleHeader;
import com.huaxinkaiye.widget.ZrcListView;
import com.huaxinkaiye.widget.ZrcListView.OnStartListener;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageView;

public class MineSetShenPiActivity extends Activity implements OnClickListener,com.huaxinkaiye.widget.ZrcListView.OnItemClickListener{
	private ZrcListView listView;
	private ImageView  im_home,im_shuaxin,im_saomiao,im_sousuo;
	private EditText ed_sousuo;
	private ShenPiAdapter shenpiadapter;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_minesetshenpi);
		initView();
	}

	private void initView() {
		// TODO Auto-generated method stub
		listView=(ZrcListView)findViewById(R.id.zListView);
		im_home=(ImageView)findViewById(R.id.im_home);
		im_home.setOnClickListener(this);
		im_shuaxin=(ImageView)findViewById(R.id.im_shuaxin);
		im_sousuo=(ImageView)findViewById(R.id.im_sousuo);
		ed_sousuo=(EditText)findViewById(R.id.ed_sousuo);
		
		// 设置下拉刷新的样式（可选，但如果没有Header则无法下拉刷新）
        SimpleHeader header = new SimpleHeader(this);
        header.setTextColor(0xff0066aa);
        header.setCircleColor(0xff33bbee);
        listView.setHeadable(header);

        // 设置加载更多的样式（可选）
        SimpleFooter footer = new SimpleFooter(this);
        footer.setCircleColor(0xff33bbee);
        listView.setFootable(footer);
		
        // 设置列表项出现动画（可选）
        listView.setItemAnimForTopIn(R.anim.zrclistview_topitem_in);
        listView.setItemAnimForBottomIn(R.anim.zrclistview_bottomitem_in);
        
        // 下拉刷新事件回调（可选）
        listView.setOnRefreshStartListener(new OnStartListener() {
            @Override
            public void onStart() {
                refresh();
            }
        });

        // 加载更多事件回调（可选）
        listView.setOnLoadMoreStartListener(new OnStartListener() {
            @Override
            public void onStart() {
                loadMore();
            }
        });
        
        shenpiadapter=new ShenPiAdapter(this);
		listView.setAdapter(shenpiadapter);
		
		listView.refresh(); // 主动下拉刷新
		
		listView.setOnItemClickListener(this);
	}

	protected void loadMore() {
		// TODO Auto-generated method stub
		
	}

	protected void refresh() {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.im_home:
			finish();
			break; 
         case R.id.im_shuaxin:
 			
 			break;
         case R.id.im_sousuo:
 			
 			break;
		}
	}

	@Override
	public void onItemClick(ZrcListView parent, View view, int position, long id) {
		// TODO Auto-generated method stub
		 Intent intent = new Intent(this,
            ShenPiDetailsActicity2.class);
		 startActivityForResult(intent, 101);
	}
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		// TODO Auto-generated method stub
		super.onActivityResult(requestCode, resultCode, data);
		/**
		 * 拿到解析完成的字符串
		 */
		if (data != null) {
			String saoma=data.getStringExtra("result");
			Intent intent=new Intent(this,ShenPiDetailsActivity.class);
			startActivity(intent);
		}
	}
}
